import Request from '@/utils/requestMain'
import { PageContent, ResponseData } from './types/login'
import { DictParams, DictRes } from '@/api/types/dict'
import { AreaRes } from '@/api/types/area'
import { OrganParams, OrganRes, UserRes, UserSearchParams } from '@/api/types/system'

// 获取字典列表
export function getDictList (params: DictParams, all: boolean = false) {
  return Request<DictRes>({
    url: `/identification/api/dict${all ? '?pid' : ''}`,
    method: 'GET',
    params
  })
}

// 获取用户信息
export function getAccountInfo () {
  return Request<any>({
    url: '/identification/api/account/info',
    method: 'GET'
  })
}

// 获取行政区划列表
export function getAreaList (params: any) {
  return Request<AreaRes>({
    url: '/identification/api/area',
    method: 'GET',
    params
  })
}
// 组织机构列表
export function getOrganList (params: OrganParams) {
  return Request<OrganRes>({
    url: '/identification/api/organ',
    method: 'GET',
    params
  })
}
// 获取大屏配置列表
export function getConfigList (params: PageContent) {
  return Request<ResponseData<any[]>>({
    url: '/compbs/api/bigscreenConfig/paginQuery',
    method: 'GET',
    params
  })
}

// 获取已启用大屏
export function getEnableConfig () {
  return Request<any>({
    url: '/compbs/api/bigscreenConfig/queryEnableData',
    method: 'GET'
  })
}

// 新增大屏配置
export function addConfig (data: any) {
  return Request<any>({
    url: '/compbs/api/bigscreenConfig/save',
    method: 'POST',
    data
  })
}

// 删除配置大屏
export function delConfig (id: number) {
  return Request<any>({
    url: `/compbs/api/bigscreenConfig/delete/${id}`,
    method: 'DELETE'
  })
}

// 编辑配置大屏
export function editConfig (data: any) {
  return Request<any>({
    url: '/compbs/api/bigscreenConfig/edit',
    method: 'POST',
    data
  })
}

// 获取组件列表
export function getComponentList () {
  return Request<any>({
    url: '/identification/api/account/menus/components',
    method: 'GET'
  })
}

// 用户管理列表
export function userList (params: UserSearchParams) {
  return Request<UserRes>({
    url: '/identification/api/users',
    method: 'GET',
    params
  })
}

// 查询地图服务
export function getMapConfig (params:any) {
  return Request({
    url: 'common/api/mapConfig/',
    method: 'GET',
    params
  })
}
